<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.11.0.min.js"></script>
</head>
<body>
<table width="100%" border="1" id="tab">
    <tr>
        <th>信用卡卡号</th>
        <th>额度</th>
        <th>所属用户</th>
        <th>余额</th>
        <th>利息</th>
        <th>还款金额</th>
    </tr>
</table>
<table width="100%" border="1">
    <tr>
        <td><input type="button" id="cz" value="充值"></td>
        <td><input type="button" id="tx" value="提现"></td>
        <td><input type="button" id="hk" value="还款"></td>
    </tr>
</table>
<table width="100%" id="shouye">
    <tr>
        <td align="center"><a href="/airong/index.html">首页</a></td>
        <!--    <td align="center"><a href="#"><input type="button" id="lc" value="理财"></a></td>-->
        <td align="center"><a href="" id="lc">理财</a></td>
        <td align="center"><a href="/airong/personalCenter.html">我的</a></td>

    </tr>
</table>
</body>
<script>
    //获取地址栏参数，name:参数名称
    function getUrlParms (name) {
        let url = window.location.href;//获取请求进来的完整url
        let tstr = url.substring(url.indexOf('?') + 1).split('&');//先截取url的?后面的参数部分，在根据&分割成参数数组
        let result = {};
        tstr.forEach((item) => {
            let res = item.split('=');//res为type,my-component1.vue。  res[0]为type，res[1为]my-component1.vue
            result[res[0]] = res[1];//构造成键值对形式 res[0]为键，res[1]为值 例：type: "my-component1.vue"
        });
        return result[name];//通过键取值
    };

    let cid = getUrlParms("cid");
    let uid = getUrlParms("uid");

    let url = "/airong/cc?action=showCCByID";
    let params = {cid: cid}
    $.get(url,params,function (data) {
        $.each(data,function (index,element) {
            if (element.amount < element.limit){
                $("#tab").append(" <tr>\n" +
                    "            <td>"+ element.id +"</td>\n" +
                    "            <td>"+ element.limit +"</td>\n" +
                    "            <td>"+ element.uid +"</td>\n" +
                    "            <td>"+ element.amount +"</td>\n" +
                    "            <td>"+ element.interest +"</td>\n" +
                    "            <td>"+ element.repayment +"</td>\n" +
                    "        </tr>")
            }else {
                $("#tab").html();
                $("#tab").html(" <tr>\n" +
                    "            <th>信用卡卡号</th>\n" +
                    "            <th>额度</th>\n" +
                    "            <th>所属用户</th>\n" +
                    "            <th>余额</th>\n" +
                    "        </tr>" +
                    " <tr>\n" +
                    "            <td>"+ element.id +"</td>\n" +
                    "            <td>"+ element.limit +"</td>\n" +
                    "            <td>"+ element.uid +"</td>\n" +
                    "            <td>"+ element.amount +"</td>\n" +
                    "        </tr>\n" +
                    "<tr>")
            }
            $("#cz").click(function () {
                if (element.amount <= 0){
                    alert("余额不足，不能充值");
                    window.location.href = "showCC.html?cid="+cid+"&uid="+uid;
                }
                window.location.href = "cz.html?uid="+element.uid+"&cid="+element.id;
            });
            $("#tx").click(function () {
                window.location.href = "tx.html?uid="+element.uid+"&cid="+element.id;
            });
            $("#hk").click(function () {
                if (Number.parseInt(0 - element.repayment) >= 0){
                    alert("您不需要还款");
                    window.location.href = "showCC.html?cid="+cid+"&uid="+uid;
                }
                window.location.href = "hk.html?uid="+element.uid+"&cid="+element.id;
            });
        });
    });
    let urll = "/airong/cc?action=getSessionID";
    let paramsl = {}
    $.get(urll,paramsl,function (sessionID){
        document.getElementById('lc').href= "products.html?uid="+sessionID;
    },"text")

</script>
<style>
    div {
        width: 100%;
        text-align: center;
    }
    #shouye{
        position: absolute;
        top: 600px;
        padding: 5px;
        margin: 4px;
        background-color: bisque;
        font-size: 20px;
        text-align: center;
        z-index: 1;
    }

</style>
</html>